package hash;

/**
 * 如果元素是 0，不必理会，如果不是 0，则按照顺序进行给原数组赋值
 */
public class Move {
    public void moveZeroes(int[] nums) {
        int n = nums.length;
        int j = 0;
        for (int i = 0; i < n; i++) {
            if (nums[i] != 0) {
                nums[j++] = nums[i];
            }
        }
        while (j < n) {
            nums[j++] = 0;
        }
    }
    public static void main(String[] args) {
        int[] nums = {0, 1, 0, 3, 12};
        Move move = new Move();
        move.moveZeroes(nums);
        for (int num : nums) {
            System.out.print(num + " ");
        }
    }
}
